package com.lgl.scsheader.system.controller;

import com.lgl.scsapi.system.model.SysUser;
import com.lgl.scsheader.base.controller.BaseController;
import com.lgl.scsheader.sameCityManage.service.SameCityOrderService;
import com.lgl.scsheader.sameCityManage.service.SameCityUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/** 
 * 后台主页controller
 */
@RestController
@RequestMapping("/main")
public class MainController extends BaseController {
	@Resource(name="sameCityOrderService")
	private SameCityOrderService sameCityOrderService;
	@Resource(name="sameCityUserService")
	private SameCityUserService sameCityUserService;

	//获取主页上的登录信息
	@RequestMapping(value = "/getLoginInfo")
	public Object getLoginInfo(){
		SysUser loginUser = getSessionUser();
		Map<String,String> map = new HashMap<>(3);
		String showName = loginUser.getNickName() == null ? loginUser.getUserName() : loginUser.getNickName();
		map.put("showName", showName);
		return map;
	}
	//获取城市订单总量
	@RequestMapping(value = "/listCityOrderTotal")
	public Object listCityOrderTotal(){
		return sameCityOrderService.listCityOrderTotal();
	}
	//获取订单总量/今天总量/昨天总量
	@RequestMapping(value = "/listTodayYesterdayTotal")
	public Object listTodayYesterdayTotal(){
		return sameCityOrderService.listTodayYesterdayTotal();
	}
	//获取订单总量/今天总量/昨天总量
	@RequestMapping(value = "/listTodayYesterdayUser")
	public Object listTodayYesterdayUser(){
		return sameCityUserService.listTodayYesterdayUser();
	}
}
